<template>
  <SDrawer v-bind="$attrs" v-model:show="show" @update:show="showChange">
    <template v-slot="slotProps">
      <component :is="isComponent" @closeDrawer="()=>{show=false}"  v-bind="{...slotProps,...$attrs}">
      </component>
    </template>
  </SDrawer>
</template>
<script setup>
import UpdateForm from "@/views/admin/sys/dict/drawer/UpdateForm.vue";
import {computed, onMounted,  ref, watch} from "vue";
import SDrawer from "@/components/public/SDrawer.vue";
import DictValue from "@/views/admin/sys/dict/drawer/DictValue.vue";


const props = defineProps({
  drawerShow:{
    type:String,
  },
})
const emit = defineEmits(['update:drawerShow'])
const show = ref(false)
watch(()=>props.drawerShow,(value)=>{
  value && value != '' && (show.value = true)
})
const isComponent = computed(()=>getComponent())
const getComponent = ()=>{
  switch (props.drawerShow){
    case 'info':
      return UpdateForm;
    case 'dictCode':
      return DictValue;
  }
  return 'div'
}
const showChange = (val)=>{
  if (!val)
    emit('update:drawerShow','')
}
onMounted(()=>{
})
</script>